The Open and Quit commands are not synchronized with the rest of the macro. If you use the Open extension to open a document with an application, you'll have to insert some kind of a wait command before the rest of the macro can work on the document. This happens because it takes some time for the "open" events to get to the Finder and for the "quit" events to get to their target applications. For example, if you want to open a SimpleText document and then select all of its text you'll have to write something like:
Open sysdisk "Documents:My SimpleText Doc"
WaitWindow "My SimpleText Doc"
Menu "Edit" "Select All"
or else:
Open sysdisk "Documents:My SimpleText Doc"
WaitApp "SimpleText"
Menu "Edit" "Select All"
Here's another example: if you want to turn off file sharing and then unmount a removable cartridge such as a SyQuest, you'll have to wait until the File Sharing Extension (which is really an invisible application) has really quit: